#define NSYMS 20  /* maximum number of symbols */
typedef struct symtab
{ char *name;
  double value;
} symtab;
symtab symtable[NSYMS];

/* symbol table lookup - insert if not found
   uses a sequential search
*/
symtab * symlook(char *s)
{ char *p;
  symtab *sp;
  /* uses the equivalence of subscripts and pointers */
  for(sp = symtable; sp < &symtable[NSYMS]; sp++)
  {/* test to see if s is in table at this location*/
  if(sp->name && !strcmp(sp->name, s))
    return sp;
  /* is this entry empty – we can use it for the new name */
  if(!sp->name)
        { sp->name = strdup(s); /* string duplicate */
    return sp;
  }
  /* otherwise continue to next */
  }
  yyerror("Too many symbols");
  exit(1);  /* cannot continue */
} /* end of symbol table lookup */
